package com.jinlia.show.modules.wxapp.controller;

import com.jinlia.show.modules.base.model.query.CompanyQuery;
import com.jinlia.show.modules.base.model.vo.CompanyVO;
import com.jinlia.show.modules.base.system.entity.Company;
import com.jinlia.show.modules.base.system.service.CompanyMapperService;
import com.jinlia.show.modules.wxapp.service.CompanyService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("company")
public class CompanyController {

    @Autowired
    CompanyService companyService;

    @PostMapping("list")
    public List<CompanyVO> getList(@RequestBody CompanyQuery companyQuery) {
        List<CompanyVO> list = companyService.getNearByLocation(companyQuery);
        return list;
    }

    @PostMapping("getOne")
    public CompanyVO getById(@RequestBody CompanyQuery companyQuery) {
        Company company = companyService.getById(companyQuery.getId());
        CompanyVO companyVO = CompanyVO.fromEntity(company);
        return companyVO;
    }
}
